

<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/jquery.min.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- element -->
<script src="https://unpkg.zhimg.com/element-ui/lib/index.js"></script>
<link rel="stylesheet" href="https://unpkg.zhimg.com/element-ui/lib/theme-chalk/index.css">

<style>

    .hang{
        width: 100%;
        height: auto;
    }

    .body{
        width: 600px;
        height: auto;
        margin: auto;
        margin-top: 150px;
    }
</style>

<div id="box">
    <div class="body">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="字符输入">
                <el-input
                        type="textarea"
                        :autosize="{ minRows: 8, maxRows: 10}"
                        placeholder="请输入内容获取的json字符串"
                        v-model="form.excel">
                </el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit">生成excel</el-button>
            </el-form-item>
        </el-form>

    </div>
</div>
<script>

    new Vue({
        el: '#box',
        data() {
            return{
                form:{
                    excel:"",
                }
            }
        },
        methods: {
            onSubmit(){
                var formData = new FormData();

                if(this.form.textarea==""){
                    this.$message({
                        message: '请先输入json',
                        type: "warning",
                        offset: 300,
                        duration: 1000,
                        center: true
                    });
                }
                 let params=this.form;

                var form = $("<form method='post'></form>");
                var input;
                form.attr({"action":'/tools/setexcel'});
                $.each(params,function (key,value) {
                    input = $("<input type='hidden'>");
                    input.attr({"name":key});
                    input.val(value);
                    form.append(input);
                });
                $(document.body).append(form);
                form.submit();
            }
        }
    })
</script>
